package com.malou.client.pagos.pagoletras;

import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.TabPanelEvent;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.core.client.GWT;
import com.malou.client.MalouConstants;

public class LetrasTabPanel extends TabPanel {

	private MalouConstants k = GWT.create(MalouConstants.class);

	public LetrasTabPanel() {
		super();
		setBorderStyle(false);
		setBodyBorder(false);
		setBorders(false);

		final TabItem tabPendiente = new TabItem(k.letraPendientePago());
		tabPendiente.add(new LetrasPendientesPanel());
		tabPendiente.setBorders(false);
		tabPendiente.setLayout(new FitLayout());

		final TabItem tabHistorial = new TabItem(k.letraHistorialPago());
		tabHistorial.add(new HistorialLetrasPanel());
		tabHistorial.setBorders(false);
		tabHistorial.setLayout(new FitLayout());

		addListener(Events.Select, new Listener<TabPanelEvent>() {
			public void handleEvent(final TabPanelEvent be) {
				final TabItem tab = be.getItem();
				if (tab.equals(tabPendiente)) {
					Letras.loader.load();
				}
				if (tab.equals(tabHistorial)) {
					Letras.loaderhistorial.load();
				}
			}
		});

		add(tabPendiente);
		add(tabHistorial);

	}
}
